﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using InstrumentCheck.ILocalService;
using InstrumentCheck.BLL;
using InstrumentCheck.Module;

namespace InstrumentCheck.WorkFlow
{
    public sealed partial class Workflow1 : StateMachineWorkflowActivity
    {
        public Workflow1()
        {
            InitializeComponent();
        }

        public FormApproveEvntArgs ApproveEventArgs { set; get; }
        public FormRejectEvntArgs RejectEventArgs { set; get; }

        private void OnStaffSubmit_Invoked(object sender, ExternalDataEventArgs e)
        {            
            FormApproveEvntArgs approve = e as FormApproveEvntArgs;
            Form_bll.Send(approve.ApplyForm, approve.Routing, approve.URL, approve.MailFrom);            
        }

        private void OnApprove_Invoked(object sender, ExternalDataEventArgs e)
        {
            FormApproveEvntArgs approve = e as FormApproveEvntArgs;
            Form_bll.Approve(approve.ApplyForm, approve.Routing, approve.URL, approve.MailFrom);
        }

        void Cancel(object sender, EventArgs e)
        {
            ActivityExecutionContext aec = sender as ActivityExecutionContext;
            aec.CloseActivity();
        }

        private void OnStaffCancel_Invoked(object sender, ExternalDataEventArgs e)
        {
            FormApproveEvntArgs approve = e as FormApproveEvntArgs;
            //Form_bll.CancelForm(approve.ApplyForm);
        }

        private void OnRejected_Invoked(object sender, ExternalDataEventArgs e)
        {
            FormRejectEvntArgs reject = e as FormRejectEvntArgs;
            //Form_bll.Reject(reject.ApproveEvntArgs.Routing, reject.RejectToFlow);
        }

        private void OnStaffSave_Invoked(object sender, ExternalDataEventArgs e)
        {
            FormApproveEvntArgs saveArgs = e as FormApproveEvntArgs;
            Form_bll.Save(saveArgs.ApplyForm);
        }

        //private void OnRejectToBoss_Invoked(object sender, ExternalDataEventArgs e)
        //{
        //}

        //private void OnRejectToCorrectRoom_Invoked(object sender, ExternalDataEventArgs e)
        //{
        //}

    }

}
